package com.deluxelx.rmo.messageboard.api.res;

import com.deluxelx.rmo.common.enums.ResponseCode;
import com.deluxelx.rmo.common.result.Result;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = true)
public class MessageBoardRes<T> extends Result<T> implements Serializable {

    private static final long serialVersionUID = -3826891914896780628L;

    public MessageBoardRes(String code, String info) {
        super(code, info);
    }

    public MessageBoardRes(String code, String info, T data) {
        super(code, info, data);
    }

    public static <T> MessageBoardRes<T> buildSuccessResult(T data) {
        return new MessageBoardRes<T>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getInfo(), data);
    }

    public static <T> MessageBoardRes<T> buildSuccessResult() {
        return new MessageBoardRes<T>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getInfo());
    }

    public static <T> MessageBoardRes<T> buildErrorResult(T data) {
        return new MessageBoardRes<T>(ResponseCode.UN_ERROR.getCode(), ResponseCode.UN_ERROR.getInfo(), data);
    }

    public static <T> MessageBoardRes<T> buildErrorResult(ResponseCode response, T data) {
        return new MessageBoardRes<T>(response.getCode(), response.getInfo(), data);
    }

    public static <T> MessageBoardRes<T> buildErrorResult(ResponseCode response) {
        return new MessageBoardRes<T>(response.getCode(), response.getInfo());
    }

}
